This map shows the current unused floor area in SF Mission District parcels. The more intense green color indicates more area unused. Click on the map to explore the area.
Sources:
https://data.sfgov.org/api/geospatial/acdm-wktn?method=export&format=GeoJSON
This map shows the current unused units in SF Mission District parcels. The more intense blue color indicates more unused units. Click on the map to explore the space.
Sources:
https://data.sfgov.org/api/geospatial/acdm-wktn?method=export&format=GeoJSON
https://data.sfgov.org/resource/h9wh-cg3m.geojson
This map shows the current unused stories in SF Mission District parcels. The more intense red color indicates more unused units.
Sources:
https://data.sfgov.org/api/geospatial/acdm-wktn?method=export&format=GeoJSON
https://data.sfgov.org/resource/h9wh-cg3m.geojson
---
title: "San Francisco Mission District Parcel Potential"
runtime: shiny
output:
flexdashboard::flex_dashboard:
storyboard: true
theme: journal
social: menu
source_code: embed
---
```{r global, include = FALSE}
library(shiny)
library(rsconnect)
library(flexdashboard)
library(tidyverse)
library(tigris)
library(tidycensus)
library(sf)
library(leaflet)
library(mapboxapi)
library(readxl)
library(dplyr)
library(tidyr)
library(plotly)
library(ggplot2)
library(jsonlite)
library(maptools)
library(tidyr)
library(dplyr)
library(purrr)
library(plotly)
sf_parcels_shape <-
st_read("https://data.sfgov.org/api/geospatial/acdm-wktn?method=export&format=GeoJSON") %>%
filter(active == "true") %>%
select(
apn = blklot,
zoning = zoning_code,
zoning_desc = zoning_district
)
temp <- tempfile()
download.file("https://sfassessor.org/sites/default/files/uploaded/2020.7.10_SF_ASR_Secured_Roll_Data_2019-2020.xlsx",destfile = temp, mode = "wb")
sf_secured <- read_excel(temp, sheet = "Roll Data 2019-2020")
datakey <- read_excel(temp, sheet = "Data Key")
usecode <- read_excel(temp, sheet = "Class Code Only")
unlink(temp)
sf_parcels <-
sf_parcels_shape %>%
left_join(
sf_secured %>%
mutate(
apn = RP1PRCLID %>%
str_replace(" ","")
)
)
mission_dist <-
tracts("CA", "San Francisco", cb = T, progress_bar = F) %>%
filter(
TRACTCE %in% c(
"022803"
)
) %>%
st_transform(4326)
mission_parcels <-
sf_parcels %>%
st_centroid() %>%
.[mission_dist, ] %>%
st_set_geometry(NULL) %>%
left_join(sf_parcels %>% select(apn)) %>%
st_as_sf() %>%
filter(!is.na(RP1PRCLID))
duplicate_shapes <-
mission_parcels %>%
as.data.frame() %>%
filter(duplicated(geometry))
condo_parcels <-
mission_parcels %>%
filter(geometry %in% duplicate_shapes$geometry)
mission_parcels %>%
st_set_geometry(NULL) %>%
group_by(zoning, zoning_desc) %>%
summarize(Freq = n())
mission_parcels_final <-
mission_parcels %>%
mutate(
zoning = case_when(
zoning == "RM-1|RM-2" ~ "RM-2",
zoning_desc == "MISSION NEIGHBORHOOD COMMERCIAL" ~ "MISSION",
zoning_desc == "MISSION NEIGHBORHOOD COMMERCIAL DISTRICT" ~ "MISSION",
TRUE ~ zoning
)
) %>%
filter(zoning != "P") %>%
as.data.frame() %>%
mutate(geometry = geometry %>% st_as_text()) %>%
group_by(geometry) %>%
summarize(
apn = first(apn),
zoning = first(zoning),
units = sum(UNITS, na.rm = T),
stories = max(STOREYNO, na.rm = T),
floorarea = sum(SQFT, na.rm = T)
) %>%
ungroup() %>%
select(-geometry) %>%
left_join(mission_parcels %>% select(apn)) %>%
st_as_sf()
sf_heights <- st_read("https://data.sfgov.org/resource/h9wh-cg3m.geojson")
mission_heights <-
sf_heights[mission_parcels_final, ]
projection <- "+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=ft +no_defs"
mission_parcels_zoning <-
mission_parcels_final %>%
st_centroid() %>%
st_join(mission_heights %>% select(gen_hght)) %>%
st_set_geometry(NULL) %>%
left_join(mission_parcels_final %>% select(apn)) %>%
st_as_sf() %>%
st_transform(projection) %>%
mutate(
lotarea = st_area(.) %>% as.numeric(),
max_floorarea = case_when(
zoning == "MISSION" ~ lotarea*2.5,
zoning %in% c("MISSION","RH-1","RH-2","RH-3","RM-1","RM-2") ~ lotarea*1.8,
zoning == "RM-3" ~ lotarea*3.6
),
unused_floorarea = ifelse(
(max_floorarea - floorarea) > 0,
(max_floorarea - floorarea),
0
),
max_units = case_when(
zoning %in% c("MISSION", "MISSION DISTRICT") ~ floor(lotarea/800),
zoning == "RH-1" ~ 1,
zoning == "RH-2" ~ 2,
zoning == "RH-3" ~ 3,
zoning == "RM-1" ~ pmax(3, floor(lotarea/800)),
zoning == "RM-2" ~ pmax(3, floor(lotarea/600)),
zoning == "RM-3" ~ pmax(3, floor(lotarea/400))
),
unused_units = ifelse(
(max_units - units) > 0,
(max_units - units),
0
),
max_height = ifelse(
is.na(gen_hght),
40,
gen_hght %>% as.numeric()
),
max_stories = floor(max_height/11),
unused_stories = ifelse(
(max_stories - stories) > 0,
(max_stories - stories),
0
)
) %>%
st_transform(4326)
```
### Current Unused Floor Area: The amount of floor space in square feet that is currently unused per parcel.
```{r}
floorarea_pal <- colorBin(
palette = "Greens",
bins = c(0,1000,5000,10000,max(mission_parcels_zoning$unused_floorarea, na.rm = T))
)
leaflet() %>%
addMapboxTiles(
style_id = "light-v9",
username = "mapbox"
) %>%
addPolygons(
data = mission_parcels_zoning,
fillColor = ~floorarea_pal(unused_floorarea),
fillOpacity = 0.75,
color = "white",
weight = 0.5,
label = ~round(unused_floorarea)
) %>%
addLegend(
data = mission_parcels_zoning,
pal = floorarea_pal,
values = ~unused_floorarea,
title = "Unused Floor Area"
)
```
***
This map shows the current unused floor area in SF Mission District parcels. The more intense green color indicates more area unused. Click on the map to explore the area.
Sources:
https://data.sfgov.org/api/geospatial/acdm-wktn?method=export&format=GeoJSON
https://stanfordfuturebay.github.io/course/dashboards.html
https://shiny.rstudio.com/gallery/
### Current Unused Units: The number of units that are currently unused per parcel.
```{r}
units_pal <- colorBin(
palette = "Blues",
bins = c(0,1,5,10,max(mission_parcels_zoning$unused_units, na.rm = T))
)
leaflet() %>%
addMapboxTiles(
style_id = "light-v9",
username = "mapbox"
) %>%
addPolygons(
data = mission_parcels_zoning,
fillColor = ~units_pal(unused_units),
fillOpacity = 0.75,
color = "white",
weight = 0.5,
label = ~round(unused_units)
) %>%
addLegend(
data = mission_parcels_zoning,
pal = units_pal,
values = ~unused_units,
title = "Additional Units
Allowed"
)
```
***
This map shows the current unused units in SF Mission District parcels. The more intense blue color indicates more unused units. Click on the map to explore the space.
Sources:
https://data.sfgov.org/api/geospatial/acdm-wktn?method=export&format=GeoJSON
https://data.sfgov.org/resource/h9wh-cg3m.geojson
https://stanfordfuturebay.github.io/course/dashboards.html
https://shiny.rstudio.com/gallery/
### Current Unused Stories: The number of stories that are currently unused per parcel.
```{r}
stories_plot <-
mission_parcels_zoning %>%
filter(unused_stories > 0) %>%
ggplot() +
geom_sf(
aes(
fill = unused_stories
),
lwd = 0
) +
theme(
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
rect = element_blank()
) +
labs(
fill = "Unused Stories"
) +
scale_fill_gradient(
low = "white",
high = "red"
)
stories_plot
```
***
This map shows the current unused stories in SF Mission District parcels. The more intense red color indicates more unused units.
Sources:
https://data.sfgov.org/api/geospatial/acdm-wktn?method=export&format=GeoJSON
https://data.sfgov.org/resource/h9wh-cg3m.geojson
https://stanfordfuturebay.github.io/course/dashboards.html
https://shiny.rstudio.com/gallery/